{
Traviesadora beta 0.2.0.13.33 (30.11.2008)
LastMod: 18.03.2009 by Prof1983

Copyright 2008, travieorama@googlemail.com

This file is part of the taviesadora project

taviesadora is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

taviesadora is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
}
unit AddContactWin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,
  TraviesadoraCore;

type
  TFrmAddContact = class(TForm)
    edtJID: TEdit;
    Label1: TLabel;
    chbAskSubscr: TCheckBox;
    edtNick: TEdit;
    Label2: TLabel;
    btnAdd: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnAddClick(Sender: TObject);
    procedure edtJIDKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    FTravCore: ITraviesadoraCore;
    procedure SetJabberID(const Value: string);
  protected
    procedure DoCreate; override;
  public
    procedure Init(TravCore: ITraviesadoraCore);
  public
    property JabberID: string write SetJabberID;
  end;

var
  FrmAddContact: TFrmAddContact;

implementation

{$R *.dfm}

{ TFrmAddContact }

procedure TFrmAddContact.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TFrmAddContact.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := cafree;
end;

procedure TFrmAddContact.btnAddClick(Sender: TObject);
begin
  FTravCore.AddContact(edtJID.Text, edtNick.Text, chbAskSubscr.Checked);
  Close;
end;

procedure TFrmAddContact.edtJIDKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (Key = VK_ReTURN) then
  begin
    btnAdd.Click;
    key := 0;
  end;
end;

procedure TFrmAddContact.SetJabberID(const Value: string);
begin
  edtJID.Text := Value;
end;

procedure TFrmAddContact.DoCreate();
begin
  edtJID.SelStart := 0;
  edtJID.SelLength := 0;
end;

procedure TFrmAddContact.Init(TravCore: ITraviesadoraCore);
begin
  FTravCore := TravCore;
end;

end.
